package com.zuma.oci.docker.param;

import com.alibaba.fastjson2.JSON;

import java.util.LinkedHashMap;
import java.util.Map;


public class ImageBuildParam extends LinkedHashMap<String, String> {


    public static final String DOCKERFILE = "dockerfile";

    public static final String T = "t";

    public static final String EXTRAHOSTS = "extrahosts";

    public static final String REMOTE = "remote";

    public static final String Q = "q";

    public static final String NOCACHE = "nocache";

    public static final String CACHEFROM = "cachefrom";

    public static final String PULL = "pull";

    public static final String RM = "rm";

    public static final String FORCERM = "forcerm";

    public static final String MEMORY = "memory";

    public static final String MEMORYSWAP = "memswap";

    public static final String CPUSHARES = "cpushares";

    public static final String CPUSETCPUS = "cpusetcpus";

    public static final String CPUPERIOD ="cpuperiod";

    public static final String CPUCFSQUOTA = "cpucfsquota";

    public static final String BUILDARGS = "buildargs";

    public static final String SHMSIZE = "shmsize";

    public static final String SQUASH = "squash";

    public static final String LABELS = "labels";

    public static final String NETWORKMODE = "networkmode";

    public static final String PLATFORM = "platform";

    public static final String TARGET = "target";

    public static final String OUTPUTS = "outputs";

    public static final String VERSION = "version";


    public ImageBuildParam set(String key, String value) {
        put(key, value);
        return this;
    }

    public ImageBuildParam buildArgs(Map<String, String> args) {
        if (args == null || args.isEmpty()) {
            return this;
        }
        System.out.println(JSON.toJSONString(args));
        return set(BUILDARGS, JSON.toJSONString(args));
    }

    public ImageBuildParam dockerfile(String dockerfile) {
        if (dockerfile == null || dockerfile.isEmpty()) {
            return this;
        }
        return set(DOCKERFILE, dockerfile);
    }

    public ImageBuildParam imageName(String imageName) {
        if (imageName == null || imageName.isEmpty()) {
            return this;
        }
        return set(T, imageName);
    }

    public ImageBuildParam platforms(String platforms) {
        if (platforms == null || platforms.isEmpty()) {
            return this;
        }
        return set(PLATFORM, platforms);
    }
}
